package indvi.cfeng;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author Cfeng
 * @date 2022/6/7
 * 这里实验编写一个Starter
 */

@Configuration
public class ThreadPoolAutoConfiguration {
    @Bean(name = "myThread")
    @ConditionalOnClass(ThreadPoolExecutor.class)   //这里一定成立，可以加入
    public ThreadPoolExecutor myThreadPool() {
        return new ThreadPoolExecutor(10,10,10, TimeUnit.SECONDS,new ArrayBlockingQueue(10));
    }
}
